package com.ruoyi.web.websocket;

import lombok.Data;

import java.io.Serializable;

@Data
public class MessageResult implements Serializable {
    private String code;      // 状态码（200成功，500失败等）
    private String message;   // 提示信息
    private Object data;      // 可选数据

    public static MessageResult success(String message) {
        return success(message, null);
    }

    public static MessageResult success(String message, Object data) {
        MessageResult result = new MessageResult();
        result.setCode("200");
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static MessageResult error(String message) {
        return error(message, null);
    }

    public static MessageResult error(String message, Object data) {
        MessageResult result = new MessageResult();
        result.setCode("500");
        result.setMessage(message);
        result.setData(data);
        return result;
    }
}
